// 宏命令：一组命令的集合。实现一次执行一批命令

const closeDoorCommand = {
    execute() {
        console.log('关门');
    }
}

const openPCCommand = {
    execute() {
        console.log('开电脑');
    }
}

const openWechatCommand = {
    execute() {
        console.log('登录微信');
    }
}

class MacroCommand {
    constructor() {
        this.commandList = [];
    }

    add(command) {
        this.commandList.push(command);
    }

    execute() {
        this.commandList.forEach(command => command.execute());
    }
}

// test
let macroCommand = new MacroCommand();
macroCommand.add(closeDoorCommand);
macroCommand.add(openPCCommand);
macroCommand.add(openWechatCommand);
macroCommand.execute();
